function count_same_elements(collection) {
  //在这里写入代码
  var obj = {}
  for (let item of collection) {
    if (item.length > 1) {
      s=item.substring(0,1)
      if(obj[s]){
        obj[s]=obj[s]+parseInt(item.replace(/[^0-9]/ig, ""));
      }else{
        obj[s]=parseInt(item.replace(/[^0-9]/ig, ""));
      }
    } else {
      if (obj[item]) {
        obj[item]++;
      } else {
        obj[item] = 1;
      }
    }
  }
  var result = []
  for (let key in obj) {
    let temp = {}
    temp.name = key;
    temp.summary = obj[key];
    result.push(temp)
  }
  return result;
}

module.exports = count_same_elements;
